package com.example.xlzx.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.xlzx.entity.Post;
import com.example.xlzx.entity.PostReply;
import com.example.xlzx.result.Result;
import com.example.xlzx.service.IPostReplyService;
import com.example.xlzx.service.IPostService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 帖子回复表 前端控制器
 * </p>
 *
 * @author 1
 * @since 2025-03-07
 */
@RestController
@Tag(name="帖子回复信息")
@RequestMapping("/xlzx")
public class PostReplyController {
    @Autowired
    private IPostReplyService postReplyService;
    @Operation(summary = "新增帖子回复")
    @PostMapping("/insetPostReply")
    public Result<Boolean> insertPostReply(@RequestBody PostReply postReply) {
        return Result.ok(postReplyService.save(postReply));
    }

    @Operation(summary = "根据id删除帖子回复")
    @DeleteMapping("/deletePostReply/{id}")
    public Result<Boolean> deletePostReply(@PathVariable Long id) {
        return Result.ok(postReplyService.removeById(id));
    }

    @Operation(summary = "修改帖子回复")
    @PutMapping("/updatePostReply")
    public Result<Boolean> updatePostReply(@RequestBody PostReply postReply) {
        return Result.ok(postReplyService.updatePostReplyInfo(postReply));
    }

    @Operation(summary = "根据id查询联系帖子回复")
    @GetMapping("/getPostReplyInfo/{id}")
    public Result<PostReply> getPostReplyInfo(@PathVariable Long id) {
        return Result.ok(postReplyService.getById(id));
    }

    @Operation(summary = "帖子回复列表")
    @GetMapping("/selectPostReply")
    public Result<List<PostReply>> selectPostReply(@RequestParam Long postId) {
        return Result.ok(postReplyService.getPostReplyList(postId));
    }
}
